-
Notifications
You must be signed in to change notification settings - Fork 420
Fix internal error in pivot_wider()
#1614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tests/testthat/_snaps/pivot-wide.md
Outdated
| Warning: | ||
| Using an external vector in selections was deprecated in tidyselect 1.1.0. | ||
| i Please use `all_of()` or `any_of()` instead. | ||
| # Was: | ||
| data %>% select(x) | ||
| # Now: | ||
| data %>% select(all_of(x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not want to see this warning in the snapshot output
tests/testthat/test-pivot-wide.R
Outdated
| # Character vector case | ||
| expect_snapshot(error = TRUE, { | ||
| pivot_wider( | ||
| df, | ||
| id_cols = c("a", "b", "c"), | ||
| names_from = name, | ||
| values_from = value | ||
| ) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a duplicate test
tests/testthat/test-pivot-wide.R
Outdated
|
|
||
| expect_snapshot(error = TRUE, { | ||
| pivot_wider( | ||
| df, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be using df2, the tests aren't useful otherwise, looks like a thinko
tests/testthat/test-pivot-wide.R
Outdated
| # Original issue scenario | ||
| x <- c(1, 2, 12, 31, 123, 2341) | ||
| df <- data.frame(x = x) | ||
|
|
||
| # This should produce a proper tidyselect error, not an internal error | ||
| expect_snapshot(error = TRUE, { | ||
| df %>% | ||
| dplyr::mutate(y = stringr::str_split(x, "")) %>% | ||
| unnest(cols = y) %>% | ||
| pivot_wider( | ||
| id_cols = x, | ||
| values_from = y, | ||
| names_from = x | ||
| ) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified this pretty dramatically to a minimal reprex with meaningful comments
|
I've gone ahead and updated everything, but I think Copilot did not do very well with these tests. I left comments above. |
|
Thanks for reviewing. This helps a lot in calibrating my expectations around autogenerating tests. I'll do another round myself next time. |
|
Thanks! |
Closes #1609
Closes #1482
Copilot wrote the code and the tests and hallucinated the snapshots. Fixed a syntax code in the test and updated snapshots. Looks legit to me now.